<?php include('config.php') ?>
<?php
    session_start();
    $user_ID=$_SESSION['user_ID'];
    $survey_ID=$_SESSION['survey_ID'];
    
    foreach($_POST AS $field => $value) {
        $sql = "UPDATE `question` SET `question_sum`=`question_sum` + $value, `question_count`=`question_count`+ 1 WHERE `ID`=$field";
        mysql_query($sql) or die ("Error in query ".mysql_error());
    }
    $sql = "INSERT INTO `completed`(`stud_ID`, `survey_ID`) VALUES ($user_ID,$survey_ID)";
    mysql_query($sql) or die ("Error in query ".mysql_error());
    header("Location: ../index.php");
?>
